year = eval(input())
month = eval(input())
day = eval(input())
s = day
if year % 400 == 0 or (year % 100 != 0 and year % 4 == 0):
    for i in range (1,month):
        if i in (1,3,5,7,8,10,12):
            s+=31
        elif i in (4,6,9,11):
            s+=30
        else:
            s+=29
else:
    for i in range (1,month):
        if i in (1,3,5,7,8,10,12):
            s+=31
        elif i in (4,6,9,11):
            s+=30
        else:
            s+=28
print(s)